package com.gs.userservice.controller;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import com.gs.userservice.config.SampleRedisConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ProjectName: springcloudapollo20190719
 * @Package: com.gs.userservice.controller
 * @Description: java类作用描述
 * @Author: guoshuai
 * @CreateDate: 2019/7/19 17:03
 * @UpdateUser: guoshuai
 * @UpdateDate: 2019/7/19 17:03
 * @UpdateRemark: The modified content
 * @Version: 1.0
 **/
@RestController
public class ApolloConfigController {

    @ApolloConfig()
    private Config config;

    @Autowired
    private Environment env;

    @Autowired
    SampleRedisConfig sampleRedisConfig;

    @Value("${com.user.name}")
    private String name;

    @Value("${system.config.api}")
    private String apiName;

    @RequestMapping("/apollo")
    public String getConfig1(){
        return "获取的用户名是："+name+",,,,端口号是："+env.getProperty("server.port");
    }
    @RequestMapping("/apollo2")
    public String getConfig2(){
        return apiName+",,,,,,:SampleRedisConfig"+sampleRedisConfig.toString();
    }


}
